﻿-- =============================================
-- System Name:    Pre-Contract
-- Component:      Create table named salesFeedback
-- Created By:     Leo Ren (leoren@wicresoft.com)
-- Created Date:   2011-5-30
-- =============================================
--创建销售反馈表
/****** Object:  Table [dbo].[SalesFeedback]    Script Date: 06/22/2011 10:26:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SalesFeedback]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SalesFeedback](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[PreContractID] [int] NOT NULL,
	[SignType] [int] NOT NULL,
	[TreatmentWay] [int] NOT NULL,
	[OperationDate] [date] NOT NULL,
	[InvoiceStatus] [int] NOT NULL,
	[CancelProcess] [int] NULL,
	[ProblemLV1] [int] NOT NULL,
	[ProblemLV2] [int] NOT NULL,
	[Comments] [nvarchar](500) NULL,
	[DashboardIssueType] [int] NULL,
	[PeopleInCharge] [nvarchar](50) NULL,
	[Creator] [int] NOT NULL,
	[CreateTime] [datetime] NOT NULL,
 CONSTRAINT [PK_SalesFeedback] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  ForeignKey [FK_SalesFeedback_DicItem_CancelProcess]    Script Date: 06/22/2011 10:26:40 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_CancelProcess]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback]  WITH CHECK ADD  CONSTRAINT [FK_SalesFeedback_DicItem_CancelProcess] FOREIGN KEY([CancelProcess])
REFERENCES [dbo].[DicItem] ([DicItemID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_CancelProcess]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback] CHECK CONSTRAINT [FK_SalesFeedback_DicItem_CancelProcess]
GO
/****** Object:  ForeignKey [FK_SalesFeedback_DicItem_DashboardIssueType]    Script Date: 06/22/2011 10:26:40 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_DashboardIssueType]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback]  WITH CHECK ADD  CONSTRAINT [FK_SalesFeedback_DicItem_DashboardIssueType] FOREIGN KEY([DashboardIssueType])
REFERENCES [dbo].[DicItem] ([DicItemID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_DashboardIssueType]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback] CHECK CONSTRAINT [FK_SalesFeedback_DicItem_DashboardIssueType]
GO
/****** Object:  ForeignKey [FK_SalesFeedback_DicItem_InvoiceStatus]    Script Date: 06/22/2011 10:26:40 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_InvoiceStatus]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback]  WITH CHECK ADD  CONSTRAINT [FK_SalesFeedback_DicItem_InvoiceStatus] FOREIGN KEY([InvoiceStatus])
REFERENCES [dbo].[DicItem] ([DicItemID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_InvoiceStatus]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback] CHECK CONSTRAINT [FK_SalesFeedback_DicItem_InvoiceStatus]
GO
/****** Object:  ForeignKey [FK_SalesFeedback_DicItem_OperationType]    Script Date: 06/22/2011 10:26:40 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_OperationType]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback]  WITH CHECK ADD  CONSTRAINT [FK_SalesFeedback_DicItem_OperationType] FOREIGN KEY([TreatmentWay])
REFERENCES [dbo].[DicItem] ([DicItemID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_OperationType]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback] CHECK CONSTRAINT [FK_SalesFeedback_DicItem_OperationType]
GO
/****** Object:  ForeignKey [FK_SalesFeedback_DicItem_ProblemLV1]    Script Date: 06/22/2011 10:26:40 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_ProblemLV1]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback]  WITH CHECK ADD  CONSTRAINT [FK_SalesFeedback_DicItem_ProblemLV1] FOREIGN KEY([ProblemLV1])
REFERENCES [dbo].[DicItem] ([DicItemID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_ProblemLV1]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback] CHECK CONSTRAINT [FK_SalesFeedback_DicItem_ProblemLV1]
GO
/****** Object:  ForeignKey [FK_SalesFeedback_DicItem_ProblemLV2]    Script Date: 06/22/2011 10:26:40 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_ProblemLV2]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback]  WITH CHECK ADD  CONSTRAINT [FK_SalesFeedback_DicItem_ProblemLV2] FOREIGN KEY([ProblemLV2])
REFERENCES [dbo].[DicItem] ([DicItemID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_ProblemLV2]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback] CHECK CONSTRAINT [FK_SalesFeedback_DicItem_ProblemLV2]
GO
/****** Object:  ForeignKey [FK_SalesFeedback_DicItem_SignType]    Script Date: 06/22/2011 10:26:40 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_SignType]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback]  WITH CHECK ADD  CONSTRAINT [FK_SalesFeedback_DicItem_SignType] FOREIGN KEY([SignType])
REFERENCES [dbo].[DicItem] ([DicItemID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_DicItem_SignType]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback] CHECK CONSTRAINT [FK_SalesFeedback_DicItem_SignType]
GO
/****** Object:  ForeignKey [FK_SalesFeedback_Employee_Creator]    Script Date: 06/22/2011 10:26:40 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_Employee_Creator]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback]  WITH CHECK ADD  CONSTRAINT [FK_SalesFeedback_Employee_Creator] FOREIGN KEY([Creator])
REFERENCES [dbo].[Employee] ([EmployeeID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_Employee_Creator]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback] CHECK CONSTRAINT [FK_SalesFeedback_Employee_Creator]
GO
/****** Object:  ForeignKey [FK_SalesFeedback_PreContractInfo]    Script Date: 06/22/2011 10:26:40 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_PreContractInfo]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback]  WITH CHECK ADD  CONSTRAINT [FK_SalesFeedback_PreContractInfo] FOREIGN KEY([PreContractID])
REFERENCES [dbo].[PreContractInfo] ([PreContractID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SalesFeedback_PreContractInfo]') AND parent_object_id = OBJECT_ID(N'[dbo].[SalesFeedback]'))
ALTER TABLE [dbo].[SalesFeedback] CHECK CONSTRAINT [FK_SalesFeedback_PreContractInfo]
GO
